{{ define "main" }}
<main class="homepage container py-6">
    <!-- Hero -->
    <div class="hero row">
        <div class="col position-relative py-lg-7{{ if not .Site.Params.homepageImage }} py-7{{ else }} pb-5{{ end }}">
            {{- with .Site.Params.homepageImage -}}
                <div class="homepage-image">
                    <img src="{{ . | relURL }}" class="img-fluid">
                </div>
            {{- end -}}

            <h1 class="display-4">{{ .Site.Title }}</h1>
            {{- with .Site.Params.description -}}
                <h3 class="font-weight-normal">{{ . | safeHTML }}</h3>
            {{- end -}}
        </div>
    </div>

    <!-- Latest article -->
    {{- range first 1 (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) -}}
        {{ $page := . }}
        <div class="latest row py-lg-5">
            <div class="col-lg-6 mb-3">
                {{- with $page.Params.images -}}
                    {{- $images := . -}}
                    {{- with $page.Site.GetPage "section" "images" -}}
                        {{- with .Resources.GetMatch (strings.TrimPrefix "/images/" (index $images 0)) -}}
                            {{- $image := .Fill "700x450" -}}
                            <a href="{{ $page.RelPermalink }}" class="d-block">
                                <img data-src="{{ $image.RelPermalink }}" class="img-fluid rounded" alt="{{ $page.Title }}">
                            </a>
                        {{- end -}}
                    {{- end -}}
                {{- end -}}
            </div>
            <div class="col-lg-6 mb-3">
                <h5 class="created text-muted text-uppercase font-weight-bold">{{ $page.Date.Format (.Site.Params.dateFormat | default "January 2, 2006" ) }}</h5>
                <h2><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></h2>

                <div class="content">
                    {{ $page.Summary }}
                </div>
            </div>
        </div>
    {{- end -}}

    <!-- Articles -->
    <div class="articles row row-cols-1 row-cols-lg-3">
        {{ range after 1 (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }}
            <div class="col mb-3">
                {{ .Render "card" }}
            </div>
        {{ end }}
    </div>
</main>
{{ end }}
